package log;

import java.lang.reflect.Field;

import indi.zjh.dp.orm.Business;
import indi.zjh.dp.type.Text;

public class Log extends Business {
	public static final int LEVEL_DEBUG = 0;
	public static final int LEVEL_INFO = 1;
	public static final int LEVEL_BUSINESS = 2;
	public static final int LEVEL_WARN = 3;
	public static final int LEVEL_ERROR = 4;
	public static final int LEVEL_FATAL = 5;
	protected Text content = new Text("undefined");
	protected int level = LEVEL_DEBUG;
	
	@Override
	public String toDictString(Field f)
	{
		if(f.getName().equals("content"))
		{
			return "日志内容, 详细描述该日志的操作者, 被操作对象, 操作内容";
		}
		else if(f.getName().equals("level"))
		{
			return "日志级别, LEVEL_DEBUG:0, LEVEL_INFO:1, LEVEL_BUSINESS:2, LEVEL_WARN:3, LEVEL_ERROR:4, LEVEL_FATAL:5";
		}
		return super.toDictString(f);
	}

	public String getContent() {
		return content.string;
	}

	public void setContent(String content) {
		this.content.string = content;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}
	
	public String getLevelString()
	{
		if(this.level == LEVEL_DEBUG)
			return "[DEBUG]";
		else if(this.level == LEVEL_INFO)
			return "[INFO]";
		else if(this.level == LEVEL_BUSINESS)
			return "[BUSINESS]";
		else if(this.level == LEVEL_WARN)
			return "[WARN]";
		else if(this.level == LEVEL_ERROR)
			return "[ERROR]";
		else if(this.level == LEVEL_FATAL)
			return "[FATAL]";
		return "[UNKNOWN]";
	}

	@Override
	public String toString() {
		return "Log [content=" + content + ", level=" + level + ", _id=" + _id + ", _v=" + _v + "]";
	}
	
	
}
